<template>
  <div class="main">
    <van-tabs v-model="catLogIndex">
      <van-tab v-for="item in catlog" v-bind:key="item.key" :title="item.name">
      </van-tab>
    </van-tabs>
    <div class="content" v-show="conIndex>0">
      <div>
        <div v-show="catLogIndex==0">
          <div class="list-wrap">
            <h5>年份</h5>
            <ul class="list">
              <li v-for="item in s_nf" @click="xj_nf_click(item)" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>产地</h5>
            <ul class="list">
              <li v-for="item in s_cd" @click="selCD(item)" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5 v-show="!isPC">类型</h5>
            <ul  v-show="!isPC" class="list">
              <li v-for="item in s_lx" :key="item.key" @click="item.sel = !item.sel" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>交货地</h5>
            <ul class="list">
              <li v-for="item in s_jhd_type.filter(n=>n.show==true)" :key="item.key" @click="xj_jhd_click(item)" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <ul v-show="xj_jhd==2" class="list">
              <li v-for="item in s_jhd2" @click="item.sel = !item.sel" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>质量</h5>
            <ul class="quality">
              <li>
                <label>等级</label>
                <select id="selDJ1">
                                              <option v-for="item in z_dj" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>长度</label>
                <select id="selCD1">
                                              <option v-for="item in z_cd" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>强力</label>
                <select id="selQL1">
                                              <option v-for="item in z_ql" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label style="width:2em;">马值</label>
                <select id="selMZ11" class="sel_w50">
                                              <option v-for="item in z_mz1" :key="item"   :value="item">{{item}}</option>
                                          </select>
                <select id="selMZ21" class="sel_w50">
                                              <option v-for="item in z_mz2" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>含杂</label>
                <select id="selHZ1">
                                              <option v-for="item in z_hz" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>整齐度</label>
                <select id="selZQD1">
                                              <option v-for="item in z_zqd" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
            </ul>
          </div>
          <div class="btns">
            <div class="left" @click="save">保存到定制</div>
          </div>
        </div>
        <div v-show="catLogIndex==3">
          <div class="list-wrap">
            <h5>年份</h5>
            <ul class="list">
              <li v-for="item in s_nf" @click="xj_nf_click(item)" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>产地</h5>
            <ul class="list">
              <li v-for="item in d_cd" @click="selCD2(item)" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>类型</h5>
            <ul class="list">
              <li v-for="item in s_lx" :key="item.key" @click="item.sel = !item.sel" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>交货地</h5>
            <ul class="list">
              <li v-for="item in s_jhd_type" :key="item.key" @click="xj_jhd_click(item)" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <ul v-show="xj_jhd==2" class="list">
              <li v-for="item in s_jhd2" @click="item.sel = !item.sel" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>质量</h5>
            <ul class="quality">
              <li>
                <label>等级</label>
                <select id="selDJ4">
                                              <option v-for="item in z_dj" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>长度</label>
                <select id="selCD4">
                                              <option v-for="item in z_cd" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>强力</label>
                <select id="selQL4">
                                              <option v-for="item in z_ql" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label style="width:2em;">马值</label>
                <select id="selMZ14" class="sel_w50">
                                              <option v-for="item in z_mz1" :key="item"   :value="item">{{item}}</option>
                                          </select>
                <select id="selMZ24" class="sel_w50">
                                              <option v-for="item in z_mz2" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>含杂</label>
                <select id='selHZ4'>
                                              <option v-for="item in z_hz" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>整齐度</label>
                <select id='selZQD4'>
                                              <option v-for="item in z_zqd" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
            </ul>
          </div>
          <div class="btns">
            <div class="left" @click="save">保存到定制</div>
          </div>
        </div>
        <div v-show="catLogIndex==2">
          <div class="list-wrap">
            <h5>产地</h5>
            <ul class="list">
              <li v-for="item in j_cd" @click="item.sel = !item.sel" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>交货地</h5>
            <ul class="list">
              <li v-for="item in s_jhd2" @click="item.sel = !item.sel" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>质量</h5>
            <ul class="quality">
              <li>
                <label>等级</label>
                <select id="selDJ3">
                                              <option v-for="item in j_z_dj" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>长度</label>
                <select id="selCD3">
                                              <option v-for="item in j_z_cd" :key="item"  :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>强力</label>
                <select id="selQL3">
                                              <option v-for="item in j_z_ql" :key="item"  :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>马值</label>
                <select id="selMZ3">
                                              <option v-for="item in j_z_mz" :key="item"  :value="item">{{item}}</option>
                                          </select>
              </li>
            </ul>
          </div>
          <div class="btns">
            <div class="left" @click="save">保存到定制</div>
          </div>
        </div>
        <div v-show="catLogIndex==1">
          <div class="list-wrap">
            <h5>产地</h5>
            <ul class="list">
              <li v-for="item in j_cd" @click="item.sel = !item.sel" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>交货地</h5>
            <ul class="list">
              <li style="width:26%;" v-for="item in j_s_jhd" @click="j_s_jhd_Click(item)" :key="item.key" :class="{'sel':item.sel}">{{item.name}}</li>
            </ul>
            <h5>质量</h5>
            <ul class="quality">
              <li>
                <label>等级</label>
                <select id="selDJ2">
                                              <option v-for="item in j_z_dj" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>长度</label>
                <select id="selCD2">
                                              <option v-for="item in j_z_cd" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>强力</label>
                <select id="selQL2">
                                              <option v-for="item in j_z_ql" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
              <li>
                <label>马值</label>
                <select id="selMZ2">
                                              <option v-for="item in j_z_mz" :key="item"   :value="item">{{item}}</option>
                                          </select>
              </li>
            </ul>
          </div>
          <div class="btns">
            <div class="left" @click="save">保存到定制</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {
    Toast
  } from "vant";
  import api from "@/api/api";
  export default {
    data() {
      return {
        catLogIndex: 0,
        conIndex: 1,
        xj_jhd: 0,
        data: {
          DengJi: "31+",
          ChangDu: "28+",
          QiangLi: "25",
          MaZhi1: "4.2",
          MaZhi2: "5.1",
          HanZa: "0.6-",
          ZhengQiDu: "81+"
        },
        z_dj: [
          "不限",
          "11",
          "21",
          "31+",
          "41+",
          "51+",
          "12+",
          "22+",
          "32+",
          "13+",
          "23+",
          "33+",
          "14+",
          "24+"
          
        ],
        z_cd: [
          "不限",
          "25+",
          "25.5+",
          "26+",
          "26.5+",
          "27+",
          "27.5+",
          "27.8+",
          "28+",
          "28.5+",
          "28.8+",
          "29+",
          "29.5+",
          "30+"
        ],
        z_ql: [
          "25",
          "25.5",
          "26",
          "26.5",
          "27",
          "27.5",
          "28",
          "28.5",
          "29",
          "不限"
        ],
        z_mz1: [
          "2.5",
          "2.8",
          "3.0",
          "3.5",
          "3.6",
          "3.7",
          "3.8",
          "3.9",
          "4.0",
          "4.1",
          "4.2",
          "4.3",
          "4.4",
          "4.5",
          "不限"
        ],
        z_mz2: [
          "3.5",
          "3.8",
          "3.9",
          "4.0",
          "4.1",
          "4.2",
          "4.3",
          "4.4",
          "4.5",
          "4.6",
          "4.7",
          "4.8",
          "4.9",
          "5.0",
          "5.1",
          "5.1+",
          "5.2",
          "5.2+",
          "5.3",
          "不限"
        ],
        z_hz: [
          "不限",
          "0.6-",
          "1.0-",
          "1.2-",
          "1.5-",
          "2.0-",
          "2.5-",
          "3.0-",
          "3.0+"
        ],
        z_zqd: ["不限", "79+", "80+", "81+", "82+", "82.5+", "83+"],
        j_z_dj: ['不限', "GM", "SM", "M+", "SLM+", "LM+"],
        j_z_cd: ['不限', "1", "1-1/32+", "1-1/16+", "1-3/32+", "1-1/8+", "1-5/32+"],
        j_z_ql: ['不限', "25+", "26+", "27+", "28+", "29+"],
        j_z_mz: ['不限', "G1", "G2", "G3", "G4", "G5", "G6", "G7"],
        catlog: [{
            name: "新疆棉",
            key: "1"
          },
          {
            name: "进口棉$",
            key: "4"
          },
          {
            name: "进口棉¥",
            key: "3"
          },
          {
            name: "地产棉",
            key: "2"
          },
        ],
        s_nf: [{
            name: "新棉",
            key: "1",
            sel: true
          },
          {
            name: "拍储棉",
            key: "2",
            sel: false
          }
        ],
        d_cd: this.$store.state.d_cd,
        j_cd: this.$store.state.j_cd,
        s_cd: [{
          name: '不限',
          key: '60',
          sel: false
        }, {
          name: '地方',
          key: '6001',
          sel: false
        }, {
          name: '兵团',
          key: '6002',
          sel: false
        }],
        s_lx: [{
            name: "手摘棉",
            key: "1",
            sel: false
          },
          {
            name: "机采棉",
            key: "2",
            sel: false
          },
          {
            name: "皮辊棉",
            key: "3",
            sel: false
          },
          {
            name: "长绒棉",
            key: "4",
            sel: false
          }
        ],
        s_ysj: [{
            name: "11",
            key: "1",
            sel: false
          },
          {
            name: "21",
            key: "2",
            sel: false
          },
          {
            name: "31",
            key: "3",
            sel: false
          },
          {
            name: "41",
            key: "4",
            sel: false
          },
          {
            name: "51",
            key: "5",
            sel: false
          },
          {
            name: "12",
            key: "6",
            sel: false
          },
          {
            name: "22",
            key: "7",
            sel: false
          },
          {
            name: "32",
            key: "8",
            sel: false
          },
          {
            name: "13",
            key: "9",
            sel: false
          },
          {
            name: "23",
            key: "10",
            sel: false
          },
          {
            name: "33",
            key: "11",
            sel: false
          },
          {
            name: "14",
            key: "12",
            sel: false
          },
          {
            name: "24",
            key: "13",
            sel: false
          }
        ],
        s_jhd_type: [{
            name: "新疆仓库",
            key: "1",
            sel: false,
            show:true
          },
          {
            name: "内地仓库",
            key: "2",
            sel: false,
            show:true
          }
        ],
        j_s_jhd: [{
            name: "不限",
            key: "0",
            sel: false
          },{
            name: "保税仓库交货",
            key: "1",
            sel: false
          },
          {
            name: "海运在途",
            key: "2",
            sel: false
          },
          {
            name: "原产地装运",
            key: "3",
            sel: false
          }
        ],
        s_jhd1: [{
            name: "南疆",
            key: "1",
            sel: false
          },
          {
            name: "北疆",
            key: "2",
            sel: false
          },
          {
            name: "东疆",
            key: "3",
            sel: false
          }
        ],
        s_jhd2: this.$store.state.s_jhd2,
        s_jyms: [{
            name: "现价成交",
            key: "1",
            sel: false
          },
          {
            name: "期货点价",
            key: "2",
            sel: false
          }
        ],
        s_ghs: [
          "A",
          "B",
          "C",
          "D",
          "E",
          "F",
          "G",
          "H",
          "I",
          "J",
          "K",
          "L",
          "M",
          "N",
          "O",
          "P",
          "Q",
          "R",
          "S",
          "T",
          "U",
          "V",
          "W",
          "X",
          "Y",
          "Z"
        ],
        s_px: [{
            name: "特价",
            key: "1",
            sel: false
          },
          {
            name: "已售",
            key: "2",
            sel: false
          },
          {
            name: "预售",
            key: "3",
            sel: false
          },
          {
            name: "挂单",
            key: "4",
            sel: false
          },
          {
            name: "保留",
            key: "5",
            sel: false
          }
        ],
        isPC:false
      };
    },
    created() {
      var id = this.$route.query.id;
      var that = this;
      if (id) {
        api.getDemandDetail({
          ID: id
        }).then(res => {
          if (res != null) {
            this.catLogIndex = parseInt(res.NeedType);
            var arrCD = res.CDName.split(';');
            if (this.catLogIndex == 3 || this.catLogIndex == 0) {
              this.s_nf.find(n => n.key == res.NeedYear).sel = true;
              if (this.catLogIndex == 0) {
                arrCD.forEach(d => {
                  if (d != '') {
                    that.s_cd.find(n => n.name == d).sel = true;
                  }
                });
              } else {
                this.d_cd.forEach(n => {
                  if (res.CDName.indexOf(n.name + ";") >= 0) {
                    n.sel = true;
                  }
                });
              }
              this.s_lx.forEach(n => {
                if (res.CType &&  res.CType.indexOf(n.name + ";") >= 0) {
                  n.sel = true;
                }
                if(!res.CType)
                {
                  this.isPC = true;
                  this.s_jhd_type[0].show = false;
                }
                
              });
              this.xj_jhd = res.JHDType;
              this.s_jhd_type.find(n => n.key == res.JHDType).sel = true;
              this.s_jhd2.forEach(n => {
                if (res.JHD.indexOf(n.name + ";") >= 0) {
                  n.sel = true;
                }
              });
              setTimeout(() => {
                $("#selDJ" + (parseInt(res.NeedType) + 1)).val(res.DengJi);
                $("#selCD" + (parseInt(res.NeedType) + 1)).val(res.ChangDu);
                $("#selQL" + (parseInt(res.NeedType) + 1)).val(res.QiangLi);
                $("#selMZ1" + (parseInt(res.NeedType) + 1)).val(res.MaZhi1);
                $("#selMZ2" + (parseInt(res.NeedType) + 1)).val(res.MaZhi2);
                $("#selHZ" + (parseInt(res.NeedType) + 1)).val(res.HanZa);
                $("#selZQD" + (parseInt(res.NeedType) + 1)).val(res.ZhengQiDu);
              }, 500);
            } else {
              this.j_cd.forEach(n => {
                if (res.CDCode.indexOf(n.key + ";") >= 0) {
                  n.sel = true;
                }
              });
              if (this.catLogIndex == 2) {
                this.s_jhd2.forEach(n => {
                  if (res.JHD.indexOf(n.name + ";") >= 0) {
                    n.sel = true;
                  }
                });
              } else if (this.catLogIndex == 1) {
                this.j_s_jhd.forEach(n => {
                  if (res.JHD.indexOf(n.name + ";") >= 0) {
                    n.sel = true;
                  }
                });
              } else {
                this.j_s_jhd.forEach(n => {
                  if (res.JHD.indexOf(n.name + ";") >= 0) {
                    n.sel = true;
                  }
                });
              }
              setTimeout(() => {
                $("#selDJ" + (parseInt(res.NeedType) + 1)).val(res.DengJi);
                $("#selCD" + (parseInt(res.NeedType) + 1)).val(res.ChangDu);
                $("#selQL" + (parseInt(res.NeedType) + 1)).val(res.QiangLi);
                $("#selMZ" + (parseInt(res.NeedType) + 1)).val(res.MaZhi1);
              }, 500);
            }
          }
        });
      } else {
        setTimeout(() => {
          $("#selDJ1").val('31+');
          $("#selCD1").val('28+');
          $("#selQL1").val('26');
          $("#selMZ11").val('4.2');
          $("#selMZ21").val('5.2+');
          $("#selHZ1").val('1.5-');
          $("#selZQD1").val('81+');

          $("#selDJ4").val('41+');
          $("#selCD4").val('27+');
          $("#selQL4").val('27');
          $("#selMZ14").val('3.8');
          $("#selMZ24").val('5.1');
          $("#selHZ4").val('2.0-');
          $("#selZQD4").val('81+');
        }, 500);
      }
    },
    methods: {
      selCD2(item) {
        item.sel = !item.sel;
        if (item.key == "01") {
          this.d_cd.forEach(n => {
            if (n.key != "01") {
              n.sel = false;
            }
          });
          
        } else {
          this.d_cd[0].sel = false;
        }
      },
      save() {
        var nf = this.s_nf.find(n => n.sel);
        var cd = this.s_cd.find(n => n.sel);
        var cdd = this.d_cd.find(n => n.sel);
        var cdj = this.j_cd.find(n => n.sel);
        var lx = "";
        this.s_lx.forEach(n => {
          if (n.sel) {
            lx += n.name + ";";
          }
        });
        var jhd = this.s_jhd_type.find(n => n.sel);
        var jhd2 = this.s_jhd2.find(n => n.sel); {
          if (this.catLogIndex == 3 || this.catLogIndex == 0) {
            if (nf == null) {
              Toast.fail("请选择年份");
              return;
            }
          }
          if (this.catLogIndex == 0) {
            if (cd == null) {
              Toast.fail("请选择产地");
              return;
            }
            if (lx == "" && nf=='1') {
              Toast.fail("请选择类型");
              return;
            }
            if (jhd == null) {
              Toast.fail("请选择交货地");
              return;
            } else {
              if (jhd.key == "2") {
                if (!this.s_jhd2.find(n => n.sel == true)) {
                  Toast.fail("请选择具体内地仓库！");
                }
              }
            }
          } else if (this.catLogIndex == 3) {
            if (cdd == null) {
              Toast.fail("请选择产地");
              return;
            }
            if (lx == "") {
              Toast.fail("请选择类型");
              return;
            }
            if (jhd == null) {
              Toast.fail("请选择交货地");
              return;
            } else {
              if (jhd.key == "2") {
                if (!this.s_jhd2.find(n => n.sel == true)) {
                  Toast.fail("请选择具体内地仓库！");
                }
              }
            }
          } else if (this.catLogIndex == 2) {
            if (cdj == null) {
              Toast.fail("请选择产地");
              return;
            }
            if (jhd2 == null) {
              Toast.fail("请选择交货地");
              return;
            }
          }
        }
        var MadeIn = "";
        var MadeInName = "";
        var jhdName = "";
        var data = {};
        if (this.catLogIndex == 0) {
          this.s_cd.forEach(n => {
            if (n.sel) {
              if (n.list) {
                let s_cd_subItem = "";
                let s_cd_subItemName = "";
                n.list.forEach(k => {
                  if (k.sel) {
                    s_cd_subItem += k.key + ";";
                    s_cd_subItemName += k.name + ";";
                  }
                });
                if (!s_cd_subItem) {
                  s_cd_subItem += n.key + ";";
                  s_cd_subItemName += n.name + ";";
                }
                MadeIn += s_cd_subItem;
                MadeInName += s_cd_subItemName;
              } else {
                MadeIn += n.key + ";";
                MadeInName += n.name + ";";
              }
            }
          }); {
            if (jhd.key == "1") {
              jhdName = jhd.name + ";";
            } else {
              this.s_jhd2.forEach(n => {
                if (n.sel) {
                  jhdName += n.name + ";";
                }
              });
            }
          }
          data = {
            DelFlag: 0,
            UserID: this.$store.state.userInfo.ID,
            UserName: this.$store.state.userInfo.XM,
            NeedType: this.catLogIndex,
            NeedYear: nf.key,
            CDCode: MadeIn,
            CDName: MadeInName,
            CType: lx,
            JHD: jhdName,
            JHDType: jhd.key,
            DengJi: $("#selDJ1").val(),
            ChangDu: $("#selCD1").val(),
            QiangLi: $("#selQL1").val(),
            MaZhi1: $("#selMZ11").val(),
            MaZhi2: $("#selMZ21").val(),
            HanZa: $("#selHZ1").val(),
            ZhengQiDu: $("#selZQD1").val()
          };
        } else if (this.catLogIndex == 3) {
          if (jhd.key == "1") {
            jhdName = jhd.name + ";";
          } else {
            this.s_jhd2.forEach(n => {
              if (n.sel) {
                jhdName += n.name + ";";
              }
            });
          }
          this.d_cd.forEach(n => {
            if (n.sel) {
              MadeInName += n.name + ";";
              MadeIn += n.key + ";";
            }
          });
          data = {
            DelFlag: 0,
            UserID: this.$store.state.userInfo.ID,
            UserName: "张三",
            NeedType: this.catLogIndex,
            NeedYear: nf.key,
            CDCode: MadeIn,
            CDName: MadeInName,
            CType: lx,
            JHDType: jhd.key,
            JHD: jhdName,
            DengJi: $("#selDJ4").val(),
            ChangDu: $("#selCD4").val(),
            QiangLi: $("#selQL4").val(),
            MaZhi1: $("#selMZ14").val(),
            MaZhi2: $("#selMZ24").val(),
            HanZa: $("#selHZ4").val(),
            ZhengQiDu: $("#selZQD4").val()
          };
        } else if (this.catLogIndex == 2) {
          this.j_cd.forEach(n => {
            if (n.sel) {
              MadeInName += n.name + ";";
              MadeIn += n.key + ";";
            }
          });
          this.s_jhd2.forEach(n => {
            if (n.sel) {
              jhdName += n.name + ";";
            }
          });
          data = {
            DelFlag: 0,
            UserID: this.$store.state.userInfo.ID,
            UserName: "张三",
            NeedType: this.catLogIndex,
            CDCode: MadeIn,
            CDName: MadeInName,
            JHD: jhdName,
            DengJi: $("#selDJ3").val(),
            ChangDu: $("#selCD3").val(),
            QiangLi: $("#selQL3").val(),
            MaZhi1: $("#selMZ3").val()
          };
        } else if (this.catLogIndex == 1) {
          this.j_cd.forEach(n => {
            if (n.sel) {
              MadeInName += n.name + ";";
              MadeIn += n.key + ";";
            }
          });
          this.j_s_jhd.forEach(n => {
            if (n.sel) {
              jhdName += n.name + ";";
            }
          });
          data = {
            DelFlag: 0,
            UserID: this.$store.state.userInfo.ID,
            UserName: "张三",
            NeedType: this.catLogIndex,
            CDCode: MadeIn,
            CDName: MadeInName,
            JHD: jhdName,
            DengJi: $("#selDJ2").val(),
            ChangDu: $("#selCD2").val(),
            QiangLi: $("#selQL2").val(),
            MaZhi1: $("#selMZ2").val()
          };
        }
        data.ID = this.$route.query.id;
        data.EntName = this.$store.state.userInfo.EntName;
        api.AddDemand(data).then(res => {
          if (res.success) {
            Toast.success("提交成功");
            this.$router.push("/demand");
          } else {
            Toast.fail("提交失败");
          }
        });
      },
      selCD(item) {
        item.sel = !item.sel;
        if (item.key == "60") {
          this.s_cd.forEach(n => {
            if (n.key != "60") {
              n.sel = false;
            }
          });
        } else {
          this.s_cd[0].sel = false;
        }
      },
      xj_jhd_click(item) {
        var d = this.s_jhd_type.find(n => n.sel);
        if (d != null) {
          d.sel = !d.sel;
        }
        item.sel = !item.sel;
        this.xj_jhd = item.key;
      },
      xj_nf_click(item) {
        var d = this.s_nf.find(n => n.sel);
        if (d != null && d.key != item.key) {
          d.sel = false;
        }
        
        item.sel = !item.sel;
        if(item.sel && item.key=='2')
        {
          this.isPC = true;
          this.s_jhd_type[0].show = false;
        }else
        {
          this.isPC = false;
          this.s_jhd_type[0].show = true;
        }
      },
      j_s_jhd_Click(item) {
        var d = this.j_s_jhd.find(n => n.sel);
        if (d != null && d.key != item.key) {
          d.sel = false;
        }
        item.sel = !item.sel;
      }
    }
  };
</script>

<style scoped lang='less'>
  .main {
    .content {
      >div {}
      .list-wrap {
        overflow-y: scroll;
        padding: 0 10px 50px 10px;
      }
      width: 100%;
      background: #fff;
      z-index: 9;
      .quality {
        margin-top: 10px;
        text-align: left;
        font-size: 12px;
        display: flex;
        flex-wrap: wrap;
        label {
          width: 3em;
          display: inline-block;
          text-align: right;
        }
        li {
          min-width: 10em;
          max-width: 10em;
          flex: 1;
          height: 2.5em;
        }
      }
      select {
        outline: 0;
        background: rgba(0, 0, 0, 0);
        width: 5em;
        height: 20px;
        font-size: 12px;
        text-align: center;
        border: 1px #ccc solid;
        border-radius: 5px;
        option {
          color: black;
          line-height: 15px;
          height: 15px;
        }
      }
      .sel_w50 {
        width: 3.5em;
      }
      .list {
        text-align: left;
        margin-top: 10px;
        li {
          display: inline-block;
          background: #f0f0f0;
          width: 20%;
          font-size: 12px;
          text-align: center;
          line-height: 2em;
          height: 2em;
          border: 1px solid #ccc;
          margin-right: 1em;
          margin-bottom: 5px;
          color: #000;
          cursor: pointer;
        }
        .sel {
          background: #2cb98e;
          color: #fff;
          border-color: #2cb98e;
        }
      }
      .btns {
        text-align: center;
        width: 100%;
        padding-top: 0;
        height: 2.5em;
        background: #fff;
        z-index: 999;
        >div {
          width: 40%;
          background: #2cb98e;
          color: #fff;
          font-size: 14px;
          height: 2em;
          line-height: 2em;
          margin-right: 20px;
        }
        .left {
          margin: 0 auto;
        }
        .right {
          float: right;
        }
      }
      h5 {
        text-align: left;
        margin-top: 0.5em;
      }
    }
  }
</style>